<template>
  <a-drawer
    :title="title"
    :width="width"
    placement="right"
    :closable="false"
    @close="close"
    :visible="visible">
  
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">

        <a-form-item label="姓名" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'xingMing', validatorRules.xingMing]" placeholder="请输入姓名"></a-input>
        </a-form-item>
        <a-form-item label="身份证号" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'shenFenZhengHao', validatorRules.shenFenZhengHao]" placeholder="请输入身份证号"></a-input>
        </a-form-item>
        <a-form-item label="民族" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-dict-select-tag type="list" v-decorator="['minZu', validatorRules.minZu]" :trigger-change="true" dictCode="gkak_mz" placeholder="请选择民族"/>
        </a-form-item>
        <a-form-item label="婚姻状况" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-dict-select-tag type="list" v-decorator="['hunYinZhuangKuang', validatorRules.hunYinZhuangKuang]" :trigger-change="true" dictCode="gkak_hyzk" placeholder="请选择婚姻状况"/>
        </a-form-item>
        <a-form-item label="籍贯" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'jiGuan', validatorRules.jiGuan]" placeholder="请输入籍贯"></a-input>
        </a-form-item>
        <a-form-item label="户籍性质" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-dict-select-tag type="list" v-decorator="['huJiXingZhi', validatorRules.huJiXingZhi]" :trigger-change="true" dictCode="gkak_hjxz" placeholder="请选择户籍性质"/>
        </a-form-item>
        <a-form-item label="结婚纪念日" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-date placeholder="请选择结婚纪念日" v-decorator="[ 'jieHunJiNianRi', validatorRules.jieHunJiNianRi]" :trigger-change="true" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="学历" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-dict-select-tag type="list" v-decorator="['xueLi', validatorRules.xueLi]" :trigger-change="true" dictCode="gkak_xl" placeholder="请选择学历"/>
        </a-form-item>
        <a-form-item label="职业" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'zhuanYe', validatorRules.zhuanYe]" placeholder="请输入职业"></a-input>
        </a-form-item>
        <a-form-item label="职称" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'zhiCheng', validatorRules.zhiCheng]" placeholder="请输入职称"></a-input>
        </a-form-item>
        <a-form-item label="原工作单位" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'yuanGongZuoDanWei', validatorRules.yuanGongZuoDanWei]" placeholder="请输入原工作单位"></a-input>
        </a-form-item>
        <a-form-item label="宗教" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-dict-select-tag type="list" v-decorator="['zongJiao', validatorRules.zongJiao]" :trigger-change="true" dictCode="gkak_zj" placeholder="请选择宗教"/>
        </a-form-item>
        <a-form-item label="老人类别" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'laoRenLeiBie', validatorRules.laoRenLeiBie]" placeholder="请输入老人类别"></a-input>
        </a-form-item>
        <a-form-item label="子女情况" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'ziNvQingKuang', validatorRules.ziNvQingKuang]" placeholder="请输入子女情况"></a-input>
        </a-form-item>
        <a-form-item label="亲属" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'qinShu', validatorRules.qinShu]" placeholder="请输入亲属"></a-input>
        </a-form-item>
        <a-form-item label="行政区" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'xingZhengQvId', validatorRules.xingZhengQvId]" placeholder="请输入行政区"></a-input>
        </a-form-item>
        <a-form-item label="社区标识" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'sheQvId', validatorRules.sheQvId]" placeholder="请输入社区标识"></a-input>
        </a-form-item>
        <a-form-item label="楼宇标识" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'louYvId', validatorRules.louYvId]" placeholder="请输入楼宇标识"></a-input>
        </a-form-item>
        <a-form-item label="房间标识" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'fangJianId', validatorRules.fangJianId]" placeholder="请输入房间标识"></a-input>
        </a-form-item>
        <a-form-item label="政治面貌" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-dict-select-tag type="list" v-decorator="['zhengZhiMianMao', validatorRules.zhengZhiMianMao]" :trigger-change="true" dictCode="gkak_zzmm" placeholder="请选择政治面貌"/>
        </a-form-item>
        <a-form-item label="家庭成员情况" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'jiaTingChengYuanQingKuang', validatorRules.jiaTingChengYuanQingKuang]" placeholder="请输入家庭成员情况"></a-input>
        </a-form-item>
        <a-form-item label="社保号" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'sheBaoHao', validatorRules.sheBaoHao]" placeholder="请输入社保号"></a-input>
        </a-form-item>
        <a-form-item label="老年证号" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'laoNianZhengHao', validatorRules.laoNianZhengHao]" placeholder="请输入老年证号"></a-input>
        </a-form-item>
        <a-form-item label="养老方式" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-dict-select-tag type="list" v-decorator="['yangLaoFangShi', validatorRules.yangLaoFangShi]" :trigger-change="true" dictCode="gkak_ylfs" placeholder="请选择养老方式"/>
        </a-form-item>
        <a-form-item label="终端类型" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-dict-select-tag type="list" v-decorator="['zhongDuanLeiXing', validatorRules.zhongDuanLeiXing]" :trigger-change="true" dictCode="gkak_zdlx" placeholder="请选择终端类型"/>
        </a-form-item>
        <a-form-item label="终端号码" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'zhongDuanHaoMa', validatorRules.zhongDuanHaoMa]" placeholder="请输入终端号码"></a-input>
        </a-form-item>
        <a-form-item label="安装时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-date placeholder="请选择安装时间" v-decorator="[ 'anZhuangShiJian', validatorRules.anZhuangShiJian]" :trigger-change="true" style="width: 100%"/>
        </a-form-item>
        <a-form-item label="附近医院" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'fuJinYiYuan', validatorRules.fuJinYiYuan]" placeholder="请输入附近医院"></a-input>
        </a-form-item>
        <a-form-item label="附近活动场所" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'fuJinHuoDongChangSuo', validatorRules.fuJinHuoDongChangSuo]" placeholder="请输入附近活动场所"></a-input>
        </a-form-item>
        <a-form-item label="紧急联系人" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'jinJiLianXiRen', validatorRules.jinJiLianXiRen]" placeholder="请输入紧急联系人"></a-input>
        </a-form-item>
        <a-form-item label="紧急联系电话" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'jinJiLianXiDianHua', validatorRules.jinJiLianXiDianHua]" placeholder="请输入紧急联系电话"></a-input>
        </a-form-item>
        <a-form-item label="附近公交地铁" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'fuJinGongJiaoDiTie', validatorRules.fuJinGongJiaoDiTie]" placeholder="请输入附近公交地铁"></a-input>
        </a-form-item>
        <a-form-item label="服务需求" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-dict-select-tag type="list" v-decorator="['fuWuXuQiu', validatorRules.fuWuXuQiu]" :trigger-change="true" dictCode="gkak_fwxq" placeholder="请选择服务需求"/>
        </a-form-item>
        <a-form-item label="特长" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'teZhang', validatorRules.teZhang]" placeholder="请输入特长"></a-input>
        </a-form-item>
        <a-form-item label="爱好" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'aiHao', validatorRules.aiHao]" placeholder="请输入爱好"></a-input>
        </a-form-item>
        <a-form-item label="身高体重血型" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'shenGaoTiZhongXueXing', validatorRules.shenGaoTiZhongXueXing]" placeholder="请输入身高体重血型"></a-input>
        </a-form-item>
        <a-form-item label="生活习惯" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'shengHuoXiGuan', validatorRules.shengHuoXiGuan]" placeholder="请输入生活习惯"></a-input>
        </a-form-item>
        <a-form-item label="疾病手术历史" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'jiBingShouShuLiShi', validatorRules.jiBingShouShuLiShi]" placeholder="请输入疾病手术历史"></a-input>
        </a-form-item>
        <a-form-item label="家族遗传" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'jiaZuYiChuan', validatorRules.jiaZuYiChuan]" placeholder="请输入家族遗传"></a-input>
        </a-form-item>
        <a-form-item label="身体残疾信息" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'shenTiCanJiXinXi', validatorRules.shenTiCanJiXinXi]" placeholder="请输入身体残疾信息"></a-input>
        </a-form-item>
        <a-form-item label="紧急联系人姓名" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'jinJiLianXiRenXingMing', validatorRules.jinJiLianXiRenXingMing]" placeholder="请输入紧急联系人姓名"></a-input>
        </a-form-item>
        <a-form-item label="紧急联系人电话" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'jinJiLianXiRenDianHua', validatorRules.jinJiLianXiRenDianHua]" placeholder="请输入紧急联系人电话"></a-input>
        </a-form-item>
        <a-form-item label="紧急联系人关系" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-dict-select-tag type="list" v-decorator="['jinJiLianXiRenGuanXi', validatorRules.jinJiLianXiRenGuanXi]" :trigger-change="true" dictCode="gkak-lxrgx" placeholder="请选择紧急联系人关系"/>
        </a-form-item>
        <a-form-item label="紧急联系人住址" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'jinJiLianXiRenZhuZhi', validatorRules.jinJiLianXiRenZhuZhi]" placeholder="请输入紧急联系人住址"></a-input>
        </a-form-item>
        <a-form-item label="慢性病种类" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <j-multi-select-tag type="list_multi" v-decorator="['manXingBingZhongLei', validatorRules.manXingBingZhongLei]" :trigger-change="true" dictCode="gkak_mxbzl" placeholder="请选择慢性病种类"/>
        </a-form-item>
        <a-form-item label="居住地址" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'juZhuDiZhi', validatorRules.juZhuDiZhi]" placeholder="请输入居住地址"></a-input>
        </a-form-item>
        
      </a-form>
    </a-spin>
    <a-button type="primary" @click="handleOk">确定</a-button>
    <a-button type="primary" @click="handleCancel">取消</a-button>
  </a-drawer>
</template>

<script>

  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import { validateDuplicateValue } from '@/utils/util'
  import JDate from '@/components/jeecg/JDate'  
  import JDictSelectTag from "@/components/dict/JDictSelectTag"
  import JMultiSelectTag from "@/components/dict/JMultiSelectTag"
  
  export default {
    name: "GkakRJianKangXinXiModal",
    components: { 
      JDate,
      JDictSelectTag,
      JMultiSelectTag,
    },
    data () {
      return {
        form: this.$form.createForm(this),
        title:"操作",
        width:800,
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
          xingMing: {rules: [
            {required: true, message: '请输入姓名!'},
          ]},
          shenFenZhengHao: {rules: [
            {required: true, message: '请输入身份证号!'},
          ]},
          minZu: {rules: [
          ]},
          hunYinZhuangKuang: {rules: [
          ]},
          jiGuan: {rules: [
            {required: true, message: '请输入籍贯!'},
          ]},
          huJiXingZhi: {rules: [
            {required: true, message: '请输入户籍性质!'},
          ]},
          jieHunJiNianRi: {rules: [
          ]},
          xueLi: {rules: [
          ]},
          zhuanYe: {rules: [
          ]},
          zhiCheng: {rules: [
          ]},
          yuanGongZuoDanWei: {rules: [
          ]},
          zongJiao: {rules: [
          ]},
          laoRenLeiBie: {rules: [
          ]},
          ziNvQingKuang: {rules: [
            {required: true, message: '请输入子女情况!'},
          ]},
          qinShu: {rules: [
          ]},
          xingZhengQvId: {rules: [
          ]},
          sheQvId: {rules: [
          ]},
          louYvId: {rules: [
          ]},
          fangJianId: {rules: [
          ]},
          zhengZhiMianMao: {rules: [
          ]},
          jiaTingChengYuanQingKuang: {rules: [
          ]},
          sheBaoHao: {rules: [
          ]},
          laoNianZhengHao: {rules: [
          ]},
          yangLaoFangShi: {rules: [
          ]},
          zhongDuanLeiXing: {rules: [
          ]},
          zhongDuanHaoMa: {rules: [
          ]},
          anZhuangShiJian: {rules: [
          ]},
          fuJinYiYuan: {rules: [
          ]},
          fuJinHuoDongChangSuo: {rules: [
          ]},
          jinJiLianXiRen: {rules: [
          ]},
          jinJiLianXiDianHua: {rules: [
          ]},
          fuJinGongJiaoDiTie: {rules: [
          ]},
          fuWuXuQiu: {rules: [
          ]},
          teZhang: {rules: [
          ]},
          aiHao: {rules: [
          ]},
          shenGaoTiZhongXueXing: {rules: [
          ]},
          shengHuoXiGuan: {rules: [
          ]},
          jiBingShouShuLiShi: {rules: [
          ]},
          jiaZuYiChuan: {rules: [
          ]},
          shenTiCanJiXinXi: {rules: [
          ]},
          jinJiLianXiRenXingMing: {rules: [
          ]},
          jinJiLianXiRenDianHua: {rules: [
          ]},
          jinJiLianXiRenGuanXi: {rules: [
          ]},
          jinJiLianXiRenZhuZhi: {rules: [
          ]},
          manXingBingZhongLei: {rules: [
          ]},
          juZhuDiZhi: {rules: [
          ]},
        },
        url: {
          add: "/org.jeecg.modules.gkak.primary/gkakRJianKangXinXi/add",
          edit: "/org.jeecg.modules.gkak.primary/gkakRJianKangXinXi/edit",
        }
      }
    },
    created () {
    },
    methods: {
      add () {
        this.edit({});
      },
      edit (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model,'xingMing','shenFenZhengHao','minZu','hunYinZhuangKuang','jiGuan','huJiXingZhi','jieHunJiNianRi','xueLi','zhuanYe','zhiCheng','yuanGongZuoDanWei','zongJiao','laoRenLeiBie','ziNvQingKuang','qinShu','xingZhengQvId','sheQvId','louYvId','fangJianId','zhengZhiMianMao','jiaTingChengYuanQingKuang','sheBaoHao','laoNianZhengHao','yangLaoFangShi','zhongDuanLeiXing','zhongDuanHaoMa','anZhuangShiJian','fuJinYiYuan','fuJinHuoDongChangSuo','jinJiLianXiRen','jinJiLianXiDianHua','fuJinGongJiaoDiTie','fuWuXuQiu','teZhang','aiHao','shenGaoTiZhongXueXing','shengHuoXiGuan','jiBingShouShuLiShi','jiaZuYiChuan','shenTiCanJiXinXi','jinJiLianXiRenXingMing','jinJiLianXiRenDianHua','jinJiLianXiRenGuanXi','jinJiLianXiRenZhuZhi','manXingBingZhongLei','juZhuDiZhi'))
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            console.log("表单提交数据",formData)
            httpAction(httpurl,formData,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }
         
        })
      },
      handleCancel () {
        this.close()
      },
      popupCallback(row){
        this.form.setFieldsValue(pick(row,'xingMing','shenFenZhengHao','minZu','hunYinZhuangKuang','jiGuan','huJiXingZhi','jieHunJiNianRi','xueLi','zhuanYe','zhiCheng','yuanGongZuoDanWei','zongJiao','laoRenLeiBie','ziNvQingKuang','qinShu','xingZhengQvId','sheQvId','louYvId','fangJianId','zhengZhiMianMao','jiaTingChengYuanQingKuang','sheBaoHao','laoNianZhengHao','yangLaoFangShi','zhongDuanLeiXing','zhongDuanHaoMa','anZhuangShiJian','fuJinYiYuan','fuJinHuoDongChangSuo','jinJiLianXiRen','jinJiLianXiDianHua','fuJinGongJiaoDiTie','fuWuXuQiu','teZhang','aiHao','shenGaoTiZhongXueXing','shengHuoXiGuan','jiBingShouShuLiShi','jiaZuYiChuan','shenTiCanJiXinXi','jinJiLianXiRenXingMing','jinJiLianXiRenDianHua','jinJiLianXiRenGuanXi','jinJiLianXiRenZhuZhi','manXingBingZhongLei','juZhuDiZhi'))
      }
      
    }
  }
</script>

<style lang="less" scoped>
/** Button按钮间距 */
  .ant-btn {
    margin-left: 30px;
    margin-bottom: 30px;
    float: right;
  }
</style>